<template>
  <el-container>
    <el-header class="user-header">
      <el-avatar :src="user.avatar" :size="90" />
      <div class="user-info">
        <h2>{{ user.name }}</h2>
        <p>联系电话：{{ user.phone }}</p>
        <p>年龄：{{ user.age }}</p>
        <p>会员状态：{{ user.isMember ? '是' : '否' }}</p>
      </div>
    </el-header>

    <el-main>
      <el-divider></el-divider>

      <h3>我的收藏</h3>
      <el-row :gutter="20">
        <el-col :span="4" v-for="restaurant in user.favoriteRestaurants" :key="restaurant.id">
          <el-card :body-style="{ padding: '0px' }" class="restaurant-card">
            <img :src="restaurant.image" class="restaurant-image" alt="餐厅图片" />
            <div class="restaurant-info">
              <h4>{{ restaurant.name }}</h4>
            </div>
          </el-card>
        </el-col>
      </el-row>

      <el-divider></el-divider>

      <h3>历史记录</h3>
      <el-table :data="user.history" style="width: 100%">
        <el-table-column prop="action" label="操作" />
        <el-table-column prop="timestamp" label="时间" />
      </el-table>
    </el-main>
  </el-container>
</template>

<script>
export default {
  data() {
    return {
      user: {
        name: '小明',
        phone: '13800000000',
        age: 28,
        isMember: true,
        avatar: 'images/TX.jpg',
        favoriteRestaurants: [
          { id: 1, name: '温馨餐厅', image: 'images/restaurantC.jpg' },
          { id: 2, name: '法式餐厅', image: 'images/restaurantD.jpg' },
          { id: 3, name: '日式餐厅', image: 'images/restaurantE.jpg' }
        ],
        history: [
          { action: '评论餐厅A', timestamp: '2024-11-20 15:30' },
          { action: '收藏餐厅B', timestamp: '2024-11-19 12:00' }
        ]
      }
    };
  }
};
</script>

<style scoped>
.user-header {
  display: flex;
  align-items: center;
  padding: 20px;
  background-color: #409eff; /* 蓝色背景 */
  gap: 20px;
  min-height: 200px;
  margin-top: 10px;
  border-radius: 8px;
  position: relative; /* 允许子元素超出容器 */
  overflow: visible; /* 允许溢出 */
}

.el-avatar {
  flex-shrink: 0;
  border: 4px solid #fff; /* 头像边框 */
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2); /* 阴影效果 */
  z-index: 2; /* 确保头像不被遮挡 */
}

.user-info {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  overflow: hidden;
  color: #fff; /* 文字颜色 */
  position: relative; /* 相对定位允许文字超出 */
  z-index: 1; /* 保证文字不会覆盖头像 */
  padding-left: 20px; /* 增加左侧内边距，防止文本紧贴头像 */
}

.user-info h2 {
  margin-bottom: 5px;
  font-size: 26px;
  font-weight: bold;
}

.user-info p {
  font-size: 16px;
  margin-bottom: 8px;
}

/* Optional styling for the main content */
.main-content {
  padding: 20px;
  background-color: #f5f7fa;
  border-radius: 8px;
}

/* Restaurant Cards */
.restaurant-card {
  border: 1px solid #ebeef5;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.restaurant-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.2);
}

.restaurant-image {
  width: 100%;
  height: 150px;
  object-fit: cover;
  border-bottom: 1px solid #ebeef5;
}

.restaurant-info {
  padding: 10px;
  text-align: center;
}

.restaurant-info h4 {
  font-size: 18px;
  color: #333;
  font-weight: bold;
}

/* Table */
.el-table {
  margin-top: 20px;
  border-radius: 8px;
  background-color: #fff;
}

.el-table th {
  background-color: #409eff;
  color: #fff;
}

.el-table .el-table__header th {
  background-color: #409eff;
}

.el-table-column {
  text-align: center;
  font-size: 16px;
  padding: 10px;
}
</style>
